<?php 
session_start();
if (isset($_POST['fdes']) && isset($_SESSION['lkey'])){
    $openid=$_POST['fdes'];
    $lkey=$_SESSION['lkey'];
	include_once("../c/config.php");
	$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
	if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
	
	if (1 == $_SESSION['cishu']){
	    $cishu=1;
	}else{
	    $cishu=2;
	}
    $query=$mysqli->query("select lkey from log_time where openid='".$openid."' and ci='".$cishu."' limit 0, 1");
    if($query->num_rows>0){
        $getLog=$query->fetch_assoc();
        if($getLog['lkey'] != $lkey){
            $mysqli->query("update log_time set num=num+1 where openid='".$openid."' and  ci='".$cishu."'  ");
        }
    }else{
        $mysqli->query("insert into log_time(openid,theday,ci,lkey,num) values('".$openid."','".date("Y-m-d H:i:s")."',".$cishu.",'".$lkey."',0) ");
       
    }
     
    echo json_encode(array('n'=>1));
	$mysqli->close();
}


?>